<?php
/**
 * 团购的EDM内容生产器
 */
class EDM_Tuan extends EDM
{
	protected function edm_data ()
	{
		$tuan = new Tuan;
		$goods_list = $tuan->today_goods();
		if (! empty($goods_list))
		{
			$this->convert_tuan_url ($goods_list);
			return $goods_list;
		}
		else
			return array();
	}

	protected function edm_tpl ()
	{
		return Kohana::config('tuan.edm.tpl');
	}

	protected function convert_tuan_url (& $tuan_list)
	{
		foreach ($tuan_list as & $item)
		{
			$url = Arr::get($item, 'tuan_detail_url');
			if (empty($url))
				continue;

			$item['tuan_detail_url'] = 'http://jia.focus.cn' . $url;
		}
	}
}
